home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Communication / NewsBase / Source / ITreeNodeD.h < prev    next >
Text File  |  1993-01-12  |  2KB  |  66 lines

  1. /*
  2.  Each node in the tree is named with a string.  No two child nodes of 
  3.  the same parent node may have the same name.  Hence each node in the tree is
  4.  uniquely addressed by a key, where a key is a list of strings. Let us call the
  5.  nth string of a key the nth subkey.  Then the nth subkey specifies the name
  6.  of a node at the nth level of a tree. The key then specifies a path through
  7.  the tree from the root.  The child nodes of a parent node is stored in an
  8.  lexigraphically ordered lists.  Additionally, each node in the tree may hold
  9.  a link to another object.  Since each subtree is also a tree the methods may
  10.  be called with any node as the root.
  11.  */
  12.  
  13. #import <objc/Object.h>
  14. #import "IOrderedListD.h"
  15.  
  16. #define MAX_TREE_STATE_DEPTH 1024
  17. typedef struct {int depth; struct {id node; int index;}nodeState[MAX_TREE_STATE_DEPTH];} NXTreeState;
  18.  
  19. #define SEARCH 1
  20. #define ADD 2
  21.  
  22. #define MAX_NO_OF_TOKENS    256
  23. void makeTreeKey(const char *, const char **, const char *);
  24.  
  25. @interface ITreeNodeD:IOrderedListD {
  26. }
  27.  
  28. /*
  29.     addNodeForKey adds the node for key theKey and any required ancestral nodes.
  30.     The id of the created node is returned.
  31. */
  32. - addNodeForKey:(char **)theKey;
  33.  
  34. /*
  35.     nodeForKey returns the id of the addressed node.
  36. */
  37. - (ITreeNodeD *)nodeForKey:(char **)theKey;
  38.  
  39. //- leaf;
  40. //- (void)setLeaf:leaf;
  41.  
  42. //- link;
  43. //- (void)setLink:link;
  44.  
  45. /*
  46.     searchForNodeWithKey will return the id of the node with key TheKey.  If the
  47.     node doesn't exists and the opCode is ADD then that node and any ancestral
  48.     nodes are add to the tree.  If the opCode is SEARCH and the node doesn't
  49.     exists then nil is returned.  If theLeaf is not nil and the node exists or
  50.     is created then that node is linked to the leaf.
  51. */
  52.  
  53. - searchForNodeWithKey:(char **)theKey withOption:(int)opCode;
  54.  
  55. /*
  56.      traverseTreeAndPerform: target: traverses the tree and makes target
  57.      perform the given method 
  58. */
  59. - (void)traverseTreeAndPerform:(SEL)theSelector target:target;
  60.  
  61. - (void)initState:(NXTreeState *)state;
  62. - nextState:(NXTreeState *)state;
  63.  
  64. @end
  65.  
  66.